import instance from './instance';

const methods = ['post', 'put', 'delete'];
const xhr = {
  get(url) {
    return instance({
      method: 'get',
      originalUrl: url,
      url,
    });
  },
};

for (let i = 0; i < methods.length; i += 1) {
  const method = methods[i];
  xhr[method] = (url, data, config) => instance({ method, url, data, originalUrl: url , ...config});
}

export default xhr;
